#include "abstractstruct.h"

AbstractStruct::AbstractStruct(StructType type) :
    FreyaAbstractStruct(), m_emType(type)
{
}

AbstractStruct::~AbstractStruct()
{
}

AbstractStruct::StructType AbstractStruct::Type()
{
    return m_emType;
}

AbstractStruct::StructType AbstractStruct::Type(const QVariant &variant)
{
    return (AbstractStruct::StructType)variant.toMap().value("FreyaType", (int)UnKnowType).toInt();
}

QVariant AbstractStruct::ToVariant()
{
    QVariantMap varMap;
    ToTemplate(varMap);
    varMap.insert("FreyaType", m_emType);
    return varMap;
}

bool AbstractStruct::FromVariant(const QVariant &variant)
{
    if(m_emType == AbstractStruct::Type(variant))
    {
        FromTemplate(variant);
        return true;
    }
    return false;
}
